import React from 'react'
import Connect from '../connect'
import { Input } from 'antd'

const Younger = ({ state, Say }) => {
  console.log('弟弟RUN')

  const onChange = (e) => {
    Say(e.target.value)
  }

  return (
    <section className="a">
      <div>
        <p>哥哥说了: {state.user.BrotherToYounger}</p>
        <p>
          告诉哥哥：
          <Input onChange={onChange} />
        </p>
        <p>{JSON.stringify(state.user)}</p>
      </div>
    </section>
  )
}

const mapDispatchToProps = (dispatch) => {
  return {
    // 发送给弟弟的话
    Say: (YoungerToBrother) => {
      dispatch({
        type: 'updateUser',
        name: 'userReducer',
        payload: {
          YoungerToBrother,
        },
      })
    },
  }
}

export default Connect(null, mapDispatchToProps)(Younger)
